home *** CD-ROM | disk | FTP | other *** search
- #include "PostPre.h"
- #include "PostWin.h"
- #include "Global.h"
-
- void do_blit(void)
- {
- blit_to_window = FALSE;
- while(!AttemptLockLayerRom(OutputWnd->WLayer)) Delay(1);
- BltBitMapRastPort(&bitmap, winxpos, winypos,
- OutputWnd->RPort, winxbase,
- winybase, winxsize, winysize, 0xC0);
- WaitBlit();
- UnlockLayerRom(OutputWnd->WLayer);
- blit_to_window = TRUE;
- }
-
- void set_scrollers(void)
- {
- UWORD hidden, vertpot, vertbody, horizpot, horizbody;
-
- hidden = max(parm.page.xsize - winxsize, 0);
- if(winxpos > hidden) winxpos = hidden;
- if(hidden > 0)
- {
- horizbody = (UWORD) (((ULONG) winxsize * MAXBODY) / (parm.page.xsize));
- horizpot = (UWORD) (((ULONG) winxpos * MAXBODY) / hidden);
- }
- else
- {
- horizbody = MAXBODY;
- horizpot = 0;
- }
- hidden = max(parm.page.ysize - winysize, 0);
- if(winypos > hidden) winypos = hidden;
- if(hidden > 0)
- {
- vertbody = (UWORD) (((ULONG) winysize * MAXBODY) / (parm.page.ysize));
- vertpot = (UWORD) (((ULONG) winypos * MAXBODY) / hidden);
- }
- else
- {
- vertbody = MAXBODY;
- vertpot = 0;
- }
- NewModifyProp(&hscrollgadg, OutputWnd, NULL,
- AUTOKNOB | FREEHORIZ | PROPNEWLOOK | PROPBORDERLESS,
- horizpot, -1, horizbody, -1, 1);
- NewModifyProp(&vscrollgadg, OutputWnd, NULL,
- AUTOKNOB | FREEVERT | PROPNEWLOOK | PROPBORDERLESS,
- -1, vertpot, -1, vertbody, 1);
- }
-
- void get_scrollers(void)
- {
- UWORD hidden;
-
- hidden = max(parm.page.xsize - winxsize, 0);
- winxpos = (((ULONG) hidden * hscrollinfo.HorizPot) + (MAXPOT/2)) / MAXPOT;
- hidden = max(parm.page.ysize - winysize, 0);
- winypos = (((ULONG) hidden * vscrollinfo.VertPot) + (MAXPOT/2)) / MAXPOT;
- }
-
-
-
- void do_gadgets(int gad_num, int incr)
- {
- BOOL blit = FALSE, change_scroller = TRUE;
-
- switch(gad_num)
- {
- case HORIZ_SCROLLER:
- case VERT_SCROLLER:
- get_scrollers();
- change_scroller = FALSE;
- blit = TRUE;
- break;
-
- case GAD_LEFT:
- if(winxpos > 0)
- {
- winxpos -= incr;
- if(winxpos < 0) winxpos = 0;
- blit = TRUE;
- }
- break;
-
- case GAD_RIGHT:
- if(winxpos < parm.page.xsize - winxsize)
- {
- winxpos += incr;
- if(winxpos > parm.page.xsize - winxsize) winxpos = parm.page.xsize - winxsize;
- blit = TRUE;
- }
- break;
-
- case GAD_UP:
- if(winypos > 0)
- {
- winypos -= incr;
- if(winypos < 0) winypos = 0;
- blit = TRUE;
- }
- break;
-
- case GAD_DOWN:
- if(winypos < parm.page.ysize - winysize)
- {
- winypos += incr;
- if(winypos > parm.page.ysize - winysize) winypos = parm.page.ysize - winysize;
- blit = TRUE;
- }
- break;
-
- default:
- blit = FALSE;
- change_scroller = FALSE;
- break;
- }
- if(blit)
- {
- if(change_scroller) set_scrollers();
- do_blit();
- }
- }
-
- int nextpage(void)
- {
- if(running && paused)
- {
- Signal((struct Task *) rendertask, 1L << pause_signal);
- if(number_of_pages)
- {
- page_number++;
- sendmenu(PSACTPAUSE, number_of_pages, page_number, 0, NULL, NULL);
- }
- return(0);
- }
- else return(STR_ID_PAUSED);
- }
-
- int previouspage(void)
- {
- if(running && paused)
- {
- if(number_of_pages)
- {
- if(page_number > 1)
- {
- page_number--;
- Signal((struct Task *) rendertask, 1L << pause_signal);
- sendmenu(PSACTPAUSE, number_of_pages, page_number, 0, NULL, NULL);
- return(0);
- }
- else
- {
- return(STR_ID_PAGE_FIRST);
- }
- }
- else
- {
- return(STR_ID_PSFILE);
- }
- }
- else
- {
- return(STR_ID_PAUSED);
- }
- }
-
- int gotopage(int next_page_number)
- {
- if(page_number != next_page_number)
- {
- Signal((struct Task *) rendertask, 1L << pause_signal);
- page_number = next_page_number;
- sendmenu(PSACTPAUSE, number_of_pages, page_number, 0, NULL, NULL);
- return(0);
- }
- else return(STR_ID_PAGE_OK);
- }
-